package com.ankiang.treeprint.manager;

import android.content.Context;

import com.ankiang.treeprint.R;
import com.ankiang.treeprint.base.BaseFragment;
import com.ankiang.treeprint.fragment.components.TRAboutFragment;
import com.ankiang.treeprint.fragment.components.TRAddGroupFragment;
import com.ankiang.treeprint.fragment.components.TRAddItemFragment;
import com.ankiang.treeprint.fragment.components.TRAddresMapFragment;
import com.ankiang.treeprint.fragment.components.TRAppVersionFragment;
import com.ankiang.treeprint.fragment.components.TRBizContactFragment;
import com.ankiang.treeprint.fragment.components.TRCalculatorFragment;
import com.ankiang.treeprint.fragment.components.TRDataAnalysisFragment;
import com.ankiang.treeprint.fragment.components.TRGalleryFragment;
import com.ankiang.treeprint.fragment.components.TRGenPhotoFragment;
import com.ankiang.treeprint.fragment.components.TRGiftSuggestFragment;
import com.ankiang.treeprint.fragment.components.TRGroupPhotoFragment;
import com.ankiang.treeprint.fragment.components.TRHelpFragment;
import com.ankiang.treeprint.fragment.components.TRHistoryKnowledgeFragment;
import com.ankiang.treeprint.fragment.components.TRHomeTreeFragment;
import com.ankiang.treeprint.fragment.components.TRListItemFragment;
import com.ankiang.treeprint.fragment.components.TRRedpacketDistributeFragment;
import com.ankiang.treeprint.fragment.components.TRSearchItemFragment;
import com.ankiang.treeprint.fragment.components.TRSeekPicFragment;
import com.ankiang.treeprint.fragment.components.TRSettingsFragment;
import com.ankiang.treeprint.fragment.components.TRSinglePhotoFragment;
import com.ankiang.treeprint.fragment.components.TRSupportFragment;
import com.ankiang.treeprint.fragment.components.TRTimeFlyFragment;
import com.ankiang.treeprint.fragment.components.TRViewImageFragment;

import org.devio.takephoto.app.TakePhotoFragment;

import java.lang.Class;
import java.util.HashMap;
import java.util.Map;

class QDWidgetContainer {
    private static QDWidgetContainer sInstance;

    private Map<Class<? extends BaseFragment>, QDDataManager.QDItemDescription> mWidgets;

    private Context context;


    private String V(int id) {
        String v = context.getResources().getString(id);
        return v;
    }

    private QDWidgetContainer(Context context) {
        this.context = context;

        mWidgets = new HashMap<>();
        mWidgets.put(TRAddItemFragment.class, new QDDataManager.QDItemDescription(TRAddItemFragment.class, V(R.string.details_op_add), R.drawable.ic_icon_help));
        mWidgets.put(TRSearchItemFragment.class, new QDDataManager.QDItemDescription(TRSearchItemFragment.class, V(R.string.search), R.drawable.ic_icon_search));

        // 识图
        mWidgets.put(TRSeekPicFragment.class, new QDDataManager.QDItemDescription(TRSeekPicFragment.class, V(R.string.seekpic_seekpic), R.drawable.ic_icon_seekpic));
        mWidgets.put(TRGroupPhotoFragment.class, new QDDataManager.QDItemDescription(TRGroupPhotoFragment.class, V(R.string.seekpic_group_photo), R.drawable.ic_icon_group_photo));
        mWidgets.put(TRTimeFlyFragment.class, new QDDataManager.QDItemDescription(TRTimeFlyFragment.class, V(R.string.seekpic_time_fly), R.drawable.ic_icon_time_fly));
        mWidgets.put(TRSinglePhotoFragment.class, new QDDataManager.QDItemDescription(TRSinglePhotoFragment.class, V(R.string.seekpic_single_photo), R.drawable.ic_icon_single_photo));
        mWidgets.put(TRGenPhotoFragment.class, new QDDataManager.QDItemDescription(TRGenPhotoFragment.class, V(R.string.seekpic_gen_photo), R.drawable.ic_icon_generate));
        mWidgets.put(TRGalleryFragment.class, new QDDataManager.QDItemDescription(TRGalleryFragment.class, V(R.string.seekpic_gallery), R.drawable.ic_icon_gallery));

        // 首页
        mWidgets.put(TRHomeTreeFragment.class, new QDDataManager.QDItemDescription(TRHomeTreeFragment.class, V(R.string.home_big_family), R.drawable.ic_icon_big_family));
        mWidgets.put(TRAddGroupFragment.class, new QDDataManager.QDItemDescription(TRAddGroupFragment.class, V(R.string.tree_op_add_group), R.drawable.ic_icon_help));
        mWidgets.put(TRListItemFragment.class, new QDDataManager.QDItemDescription(TRListItemFragment.class, V(R.string.list_item), R.drawable.ic_icon_help));

        // 发现
        mWidgets.put(TRHistoryKnowledgeFragment.class, new QDDataManager.QDItemDescription(TRHistoryKnowledgeFragment.class, V(R.string.explore_history_knowledge), R.drawable.ic_icon_example_data));
        mWidgets.put(TRDataAnalysisFragment.class, new QDDataManager.QDItemDescription(TRDataAnalysisFragment.class, V(R.string.explore_analysis), R.drawable.ic_icon_data_analysis));
        mWidgets.put(TRGiftSuggestFragment.class, new QDDataManager.QDItemDescription(TRGiftSuggestFragment.class, V(R.string.explore_gift_suggest), R.drawable.ic_icon_gift_suggest));
        mWidgets.put(TRRedpacketDistributeFragment.class, new QDDataManager.QDItemDescription(TRRedpacketDistributeFragment.class, V(R.string.explore_redpacket_distribute), R.drawable.ic_icon_redpacket));
        mWidgets.put(TRAddresMapFragment.class, new QDDataManager.QDItemDescription(TRAddresMapFragment.class, V(R.string.explore_address_map), R.drawable.ic_icon_address_map));
        mWidgets.put(TRCalculatorFragment.class, new QDDataManager.QDItemDescription(TRCalculatorFragment.class, V(R.string.explore_calculator), R.drawable.ic_icon_calculator));

        // 我的
        mWidgets.put(TRSettingsFragment.class, new QDDataManager.QDItemDescription(TRSettingsFragment.class, V(R.string.me_func_setting), R.drawable.ic_icon_settings));
        mWidgets.put(TRAboutFragment.class, new QDDataManager.QDItemDescription(TRAboutFragment.class, V(R.string.me_func_about), R.drawable.ic_icon_about));
        mWidgets.put(TRAppVersionFragment.class, new QDDataManager.QDItemDescription(TRAppVersionFragment.class, V(R.string.me_func_app_version), R.drawable.ic_icon_app_version));
        mWidgets.put(TRSupportFragment.class, new QDDataManager.QDItemDescription(TRSupportFragment.class, V(R.string.me_func_support), R.drawable.ic_icon_support));
        mWidgets.put(TRBizContactFragment.class, new QDDataManager.QDItemDescription(TRBizContactFragment.class, V(R.string.me_func_biz_contact), R.drawable.ic_icon_biz_contact));
        mWidgets.put(TRHelpFragment.class, new QDDataManager.QDItemDescription(TRHelpFragment.class, V(R.string.me_func_help), R.drawable.ic_icon_help));
        mWidgets.put(TakePhotoFragment.class, new QDDataManager.QDItemDescription(TakePhotoFragment.class, V(R.string.me_func_help), R.drawable.ic_icon_help));
        mWidgets.put(TRViewImageFragment.class, new QDDataManager.QDItemDescription(TRViewImageFragment.class, V(R.string.me_func_help), R.drawable.ic_icon_help));


    }

    public static QDWidgetContainer getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new QDWidgetContainer(context);
        }
        sInstance.setContext(context);
        return sInstance;
    }

    public QDDataManager.QDItemDescription get(Class<? extends BaseFragment> fragment) {
        return mWidgets.get(fragment);
    }

    public void setContext(Context context) {
        this.context = context;
    }
}
